package com.training.java.core.collections.car.pre15;

import java.awt.List;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class CollectionsDemo1 {

	public static void main(String[] args) {

		// instantiating object Car
		Car1 carFord = new Car1("1234", "Ford", "Focus");
		Car1 carToyota = new Car1("2345", "Toyota", "Camry");

		// Creating the container collections

		Collection cars = new ArrayList();

		// List cars = new ArrayList();

		// Add the objects to the container
		cars.add(carFord);
		cars.add(carToyota);

		// iterate

		Iterator ite = cars.iterator();
		while (ite.hasNext()) {
			Car1 aCar = (Car1) ite.next();// TypeCasting...

			// printing the car details
			System.out.println("*************************");
			System.out.println("Vin Number = " + aCar.getVinNumber());
			System.out.println("Make = " + aCar.getMake());
			System.out.println("Model = " + aCar.getModel());
		}

	}
}
